<?php
require_once(dirname(__FILE__) . '/app.php');

$id = abs(intval($_GET['id']));

$constellations = array(
	'1' => '水瓶座',
	'2' => '双鱼座',
	'3' => '白羊座',
	'4' => '金牛座',
	'5' => '双子座',
	'6' => '巨蟹座',
	'7' => '狮子座',
	'8' => '处女座',
	'9' => '天枰座',
	'10' => '天蝎座',
	'11' => '射手座',
	'12' => '摩羯座',
);

$degrees = array(
	'1' => '本科',
	'2' => '硕士',
	'3' => '博士',
	'4' => '其他',
);

//check the day guest
if (!$id || !$guest = Table::FetchForce('guest', $id) ) {
	redirect( WEB_ROOT . '/guest/index.php');
}

/* refer */
if ($_rid = abs(intval($_GET['r']))) { 
	if($_rid) cookieset('_rid', abs(intval($_GET['r'])));
	redirect( WEB_ROOT . "/guest.php?id={$id}");
}

//$city = Table::Fetch('category', $guest['city_id']);
//f(!$city) { $city = array('id' => 0, 'name' => '全部', ); }

$pagetitle = $guest['title'];

//$discount_price = $guest['market_price'] - $guest['guest_price'];
//$discount_rate = $guest['guest_price']/$guest['market_price']*10;

$left = array();
$now = time();
$diff_time = $left_time = $guest['end_time']-$now;

$left_day = floor($diff_time/86400);
$left_time = $left_time % 86400;
$left_hour = floor($left_time/3600);
$left_time = $left_time % 3600;
$left_minute = floor($left_time/60);
$left_time = $left_time % 60;


/* progress bar size */
//$bar_size = ceil(190*($guest['now_number']/$guest['min_number']));
//$bar_offset = ceil(5*($guest['now_number']/$guest['min_number']));

//$partner = Table::Fetch('partner', $guest['partner_id']);

/* other guests */
if ( abs(intval($INI['system']['sideguest'])) ) {
	$oc = array( 
			"id <> {$id}",
			"begin_time < {$now}",
			"end_time > {$now}",
			);
	$others = DB::LimitQuery('guest', array(
				'condition' => $oc,
				'order' => 'ORDER BY id DESC',
				'size' => abs(intval($INI['system']['sideguest'])),
				));
}

//$guest['state'] = guest_state($guest);

/* your order */
/*
if ($login_user_id && 0==$guest['close_time']) {
	$order = DB::LimitQuery('order', array(
		'condition' => array(
			'guest_id' => $id,
			'user_id' => $login_user_id,
			'state' => 'unpay',
		),
		'one' => true,
	));
}
*/
/* end order */

include template('guest_view');
